package String;

public class _344_ReverseString {
    //solution 1:use stringbuffer 5ms
    public String reverseString(String s) {
        StringBuffer sb = new StringBuffer(s);
        s = sb.reverse().toString();
        return s;
    }

    //solution 2:switch directly 3ms
    public String reverseString1(String s) {
        char[] c = s.toCharArray();
        int i=0,j=c.length-1;
        while (i < j) {
            char temp = c[i];
            c[i] = c[j];
            c[j] = temp;
            i++;
            j--;
        }
        return String.valueOf(c);
    }
}
